﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ChangeYWLB : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            InitData();

        }

    }
    public void InitData()
    {
        int YWLBid = int.Parse(Request["ID"].ToString());   //取出传递过来的id
        using (DataClassesDataContext ds = new DataClassesDataContext())
        {
            var r = (from q in ds.YeWuZiLiao
                     where q.id == YWLBid
                     select q).FirstOrDefault();

            this.TextBoxLBMC.Text = r.mingcheng.ToString();
        }
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        if (Page.IsValid)
        {

            if (Request["ID"] != null)                                  //如果是修改题目信息
            {
                using (DataClassesDataContext ds = new DataClassesDataContext())
                {
                    int YWLBid = int.Parse(Request["ID"].ToString());   //取出传递过来的试题编号
                    var r = (from q in ds.YeWuZiLiao
                             where q.id == YWLBid
                             select q).FirstOrDefault();
                    r.mingcheng = this.TextBoxLBMC.Text.Trim().ToString();
                    ds.SubmitChanges();

                    Response.Write("<script>alert('修改成功！');</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('修改失败！');</script>");
            }

        }
    }
}